/* Copyright (C) 2016-2017 HangZhou Zenzet Technology Co., Ltd.
 * All right reserved

 * File:lktshm.h
 * Author:guojianchuan
 * Date:2017-06-29

 */

#ifndef LKT_SHM_H
#define LKT_SHM_H

class lktshm{
    public:
        lktshm (void);
        ~lktshm (void);
        
        bool init(void);
        
        bool isAttachSHM (void);
        bool attachSHM (void);
        void detachSHM (void);
        
        bool decodePv(void);
        bool decodeMasterKey(void);
        int decodeDataKeyIv(unsigned char* key, unsigned char* iv);
        
        const char* getdatakey(void);
        const char* getdataiv(void);
        const char* getb64appdatakey(void);
        const char* getb64appdataiv(void);
        
        int readLock (void);
        int readUnLock (void);
        DATA_SHM_S* getshm(void);
        
    private:
        bool initOK;
        
        bool attach;
        
        DATA_SHM_S *datashm;
        
        DATABASE_INSTANCE_S *dbInstance;
        
        stringbuffer m_pv;
        
        stringbuffer m_masterKey;
        
        stringbuffer m_iv;

        stringbuffer b64appdatakey;

        stringbuffer b64appdataiv;
        
        stringbuffer datakey;
        
        stringbuffer dataiv;
};


#endif

